#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    prepare_Server(&server, 2, "4095", NULL, 5);
    if(start_Server(&server) == SERVER_ACTIVE)
        ui->actionStart->setEnabled(false);
}

MainWindow::~MainWindow()
{
    delete ui;
    destroy_Server(&server);
}

int main(int argc, char ** argv)
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    return a.exec();
}

void MainWindow::on_actionStart_triggered()
{
    if(start_Server(&server) == SERVER_ACTIVE)
    {
        ui->actionStart->setEnabled(false);
        ui->actionStop->setEnabled(true);
    }
}

void MainWindow::on_actionStop_triggered()
{
    close_Server(&server);
    ui->actionStop->setEnabled(false);
    ui->actionStart->setEnabled(true);
}
